/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.Service.Utilities
*        文件名:             ClientCache.cs
*        创建系统时间:       2012/11/2 19:07:01
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.Service.Utilities
{
    using System.Data;
    using ECP.Model;
    using ECP.Utilities;

    public partial class ClientCache
    {
        private DataTable dtMoule = new DataTable(BaseModuleTable.TableName);
        private DataTable dtOrganize;
        private DataTable dtPermission;
        private DataTable dtUserMoule = new DataTable(BaseModuleTable.TableName);
        private static ClientCache instance = null;
        private static object locker = new object();

        private ClientCache()
        {
        }

        public DataTable GetOrganizeList(BaseUserInfo userInfo)
        {
            if ((this.dtOrganize == null) || !BaseSystemInfo.ClientCache)
            {
                this.dtOrganize = ServiceManager.Instance.OrganizeService.GetList(userInfo);
            }
            this.dtOrganize.DefaultView.Sort = BaseOrganizeTable.FieldSortCode;
            return this.dtOrganize;
        }

        public DataTable GetPermission(BaseUserInfo userInfo)
        {
            if ((this.dtPermission == null) || !BaseSystemInfo.ClientCache)
            {
                this.dtPermission = ServiceManager.Instance.PermissionService.GetPermissionDT(userInfo);
            }
            return this.dtPermission;
        }

        public DataTable DTMoule
        {
            get
            {
                return this.dtMoule;
            }
            set
            {
                this.dtMoule = value;
            }
        }

        public DataTable DTOrganize
        {
            get
            {
                return this.dtOrganize;
            }
            set
            {
                this.dtOrganize = value;
            }
        }

        public DataTable DTPermission
        {
            get
            {
                return this.dtPermission;
            }
            set
            {
                this.dtPermission = value;
            }
        }

        public DataTable DTUserMoule
        {
            get
            {
                return this.dtUserMoule;
            }
            set
            {
                this.dtUserMoule = value;
            }
        }

        public static ClientCache Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (locker)
                    {
                        if (instance == null)
                        {
                            instance = new ClientCache();
                        }
                    }
                }
                return instance;
            }
        }
    }
}